from __future__ import annotations

from datetime import datetime
from typing import Optional

from app.schemas.common import APIModel, Timestamped


class DecisionOption(APIModel):
  label: str


class DecisionPresetBase(APIModel):
  title: str
  options: list[str]
  style: str = "wheel"
  is_shared: bool = False
  color_seed: Optional[str] = None


class DecisionPresetCreate(DecisionPresetBase):
  pass


class DecisionPresetUpdate(APIModel):
  title: Optional[str] = None
  options: Optional[list[str]] = None
  style: Optional[str] = None
  is_shared: Optional[bool] = None
  color_seed: Optional[str] = None


class DecisionPresetResponse(DecisionPresetBase, Timestamped):
  id: int
  usage_count: int
  last_used_at: Optional[datetime] = None
  last_result: Optional[str] = None


class DecisionSpinRequest(APIModel):
  options: list[str]
  title: Optional[str] = None
  style: str = "wheel"


class DecisionSpinResult(APIModel):
  title: str
  options: list[str]
  selected_index: int
  selected_value: str
  preset_id: Optional[int] = None
